Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 6a4ed6a04836dce34d43b43e7e3512705342c086


Parents : ca3ef05
Author : Sudo-Ivan <ivan@quad4.io>
Signature : Signature validation error
Date : 2026-01-14T17:45:20-06:00

Fix WebAudioBridge to manage event loop retrieval

- Introduced a property for accessing the event loop, allowing for better handling of both running and fallback scenarios.
- Updated the internal loop management to improve compatibility with asynchronous operations.

Changes

1 files changed, 16 insertions(+), 1 deletions(-)


Diff

diff --git a/meshchatx/src/backend/web_audio_bridge.py b/meshchatx/src/backend/web_audio_bridge.py
index 7d018466..2cbf0f3e 100644
--- a/meshchatx/src/backend/web_audio_bridge.py
+++ b/meshchatx/src/backend/web_audio_bridge.py
@@ -91,9 +91,24 @@ class WebAudioBridge:
self.tx_source: WebAudioSource | None = None
self.rx_sink: WebAudioSink | None = None
self.rx_tee: Tee | None = None
- self.loop = asyncio.get_event_loop()
+ self._loop = None
self.lock = threading.Lock()
+ @property
+ def loop(self):
+ if self._loop:
+ return self._loop
+
+ try:
+ self._loop = asyncio.get_running_loop()
+ except RuntimeError:
+ # Fallback to finding it via AsyncUtils if possible
+ from .async_utils import AsyncUtils
+
+ self._loop = AsyncUtils.main_loop
+
+ return self._loop
+
def _tele(self):
return getattr(self.telephone_manager, "telephone", None)


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────